<?php
/**
 * 上传控制类
 * User: Administrator
 * Date: 2018/11/2 0002
 * Time: 22:07
 */

namespace app\wx\controller;

use library\AliOss;
use exception\ResponsableException;
class Upload extends  CommonController
{
    protected $_require_login = true;
    /**
     * 上传
     */
    public function index()
    {

      try{
       //var_dump($_POST);
//             halt($this->request->param());
           //  dump($_FILES);exit;
             $avator = $this->request->file('avatar');
             $e= AliOss::upload($avator);
             return $this->response->api(['url'=>$e['info']['url']],self::SUCCESS_CODE,'上传成功');
       }catch (\Exception $e){
             return $this->response->api([],self::ERROR_CODE,'上传失败');
        }
    }



}